<?php
namespace BP\Sys;
class UIConfig {
	public $HisEn;	// Entity
	public $HisAP;	// AtPara
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__Entity ($en) // [Entity en]
	{
		$me = new self();
		$me->HisEn = $en;
		$cfg = EnCfg::constructor__String($en);
		$paraStr = $cfg->getUI();
		if (($DataType->IsNullOrEmpty($paraStr) ==  TRUE ))
		{
			$paraStr = "@UIRowStyleGlo=0@IsEnableDouclickGlo=1@IsEnableRefFunc=1@IsEnableFocusField=1@IsEnableOpenICON=1@FocusField=''@WinCardH=600@@WinCardW=800@ShowColumns=";
		}
		$me->HisAP = new AtPara($paraStr);
		return $me;
	}
	public function getShowColumns () 
	{
		$colstr = $this->HisAP->GetValStrByKey("ShowColumns");
		if ($DataType->IsNullOrEmpty($colstr))
		{
			return array();
		}
		return $colstr->split("[,]+");
	}
	public function getMoveToShowWay () 
	{
		return $MoveToShowWay->forValue($this->HisAP->GetValIntByKey("MoveToShowWay"));
	}
	public function getEditerType () 
	{
		return $EditerType->forValue($this->HisAP->GetValIntByKey("EditerType"));
	}
	public function getMoveTo () 
	{
		$s = $this->HisAP->GetValStrByKey("MoveTo");
		return $s;
	}
	public function getUIRowStyleGlo () 
	{
		return $this->HisAP->GetValIntByKey("UIRowStyleGlo");
	}
	public function getIsEnableDouclickGlo () 
	{
		return $this->HisAP->GetValBoolenByKey("IsEnableDouclickGlo");
	}
	public function getIsEnableRefFunc () 
	{
		return $this->HisAP->GetValBoolenByKey("IsEnableRefFunc");
	}
	public function getIsEnableFocusField () 
	{
		return $this->HisAP->GetValBoolenByKey("IsEnableFocusField");
	}
	public function getIsEnableOpenICON () 
	{
		return $this->HisAP->GetValBoolenByKey("IsEnableOpenICON");
	}
	public function getFocusField () 
	{
		$s = $this->HisAP->GetValStrByKey("FocusField");
		if ($DataType->IsNullOrEmpty($s))
		{
			if ($this->HisEn->getEnMap()->getAttrs()->Contains("Name"))
			{
				return "Name";
			}
			if ($this->HisEn->getEnMap()->getAttrs()->Contains("Title"))
			{
				return "Title";
			}
		}
		return $s;
	}
	public function getWinCardW () 
	{
		return $this->HisAP->GetValIntByKey("WinCardW");
	}
	public function getWinCardH () 
	{
		return $this->HisAP->GetValIntByKey("WinCardH");
	}
	public function Save () 
	{
		$cfg = EnCfg::constructor__String($this->HisEn);
		$cfg->setUI($this->HisAP->GenerAtParaStrs());
		return $cfg->Save();
	}
}
?>
